package com.aishua.fire.controller.app;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.aishua.fire.common.JsonArrayResult;
import com.aishua.fire.common.JsonObjectResult;
import com.aishua.fire.common.anno.ModuleService;
import com.aishua.fire.common.anno.PermMapping;
import com.aishua.fire.common.constant.BigMenuConstants;
import com.aishua.fire.common.constant.ModuleConstants;
import com.aishua.fire.entity.app.APPExerciseBasicReqInfo;
import com.aishua.fire.entity.app.APPExerciseBasicReqInfo_wcc;
import com.aishua.fire.entity.app.APPExerciseConclusionReqInfo;
import com.aishua.fire.entity.app.APPExerciseDataRespInfo;
import com.aishua.fire.entity.app.APPExerciseDelayReqInfo;
import com.aishua.fire.entity.app.APPExerciseFeedBack;
import com.aishua.fire.entity.app.APPExerciseFeedBack_Detail;
import com.aishua.fire.entity.app.AppCheckItemDetailsInfo;
import com.aishua.fire.entity.app.AppCheckPlanDetailsInfo;
import com.aishua.fire.entity.app.AppCheckPlanRespInfo;
import com.aishua.fire.entity.app.AppCheckPointDetailsInfo;
import com.aishua.fire.entity.app.AppDutyContentInfo;
import com.aishua.fire.entity.app.AppUserCallRecordInfo;
import com.aishua.fire.entity.app.App_AddPlanRecordInfo;
import com.aishua.fire.entity.app.App_AddressBookInfo;
import com.aishua.fire.entity.app.App_PlanRecordInfo;
import com.aishua.fire.entity.app.GetAppOrganizationAndUserInfo;
import com.aishua.fire.entity.app.IfAgreePlanDelayInfo;
import com.aishua.fire.entity.drillrecord.App_DrillRecordCatalogList;
import com.aishua.fire.entity.emergencyPre.EmergencyPreDetailsRespInfo;
import com.aishua.fire.entity.emergencyPre.EmergencyPreRespInfo;
import com.aishua.fire.entity.emergencyPre.ExercisePlanDataRespInfo;
import com.aishua.fire.entity.material.MaterialAddressList;
import com.aishua.fire.entity.material.MaterialDetailRecordInfo;
import com.aishua.fire.entity.material.MaterialDetailRecordInfoList;
import com.aishua.fire.entity.material.MaterialDetailsList;
import com.aishua.fire.entity.preExercise.ExercisePlanInfo;
import com.aishua.fire.entity.statutestudy.StatuteStudyList;
import com.aishua.fire.service.AppOperationService;
import com.aishua.fire.service.CheckManagerService;
import com.aishua.fire.service.EmergencyPreManagerService;
import com.aishua.fire.service.PreExerciseManagerService;
import com.aishua.fire.service.StatuteStudyService;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Api(value = "APP端操作相关",tags = {"APP端操作相关"})
@Controller
public class AppOperationController {

	@Autowired
	private AppOperationService appService;
	
	@Autowired
	private StatuteStudyService studyService;
	
	@Autowired
	private EmergencyPreManagerService emergencyPreService;
	
	@Autowired
	private CheckManagerService checkManagerService;
	
	@Autowired
	private PreExerciseManagerService preExerciseManagerService;
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_插入APP拨号记录")
	@PostMapping(value = { "/app/setCallRecord" })
	public ResponseEntity<JsonObjectResult> insertCallRecord(ServletRequest servletRequest, @RequestBody AppUserCallRecordInfo callInfo) 
	{
		// （获取当前账号id接口）
		/*HttpServletRequest req = (HttpServletRequest) servletRequest;
		String sessionId = CookieUtils.getCookie(req, "sessionId");
		
		//根据sessionId获取当前账号id
		Session s = appService.findByAppSessionId(sessionId);*/
		
		log.info("APP_插入APP拨号记录 :{}",callInfo);

		appService.insertCallRecord(callInfo.getUser_id(), callInfo.getPhone());
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);

		return ResponseEntity.ok(r);
	}
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_获取APP拨号记录")
	@GetMapping(value = { "/app/getCallRecord" })
	public ResponseEntity<JsonArrayResult> getCallRecord(ServletRequest servletRequest,@RequestParam(name = "user_id") String user_id,
			@RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize) 
	{
		log.info("APP_获取APP拨号记录 :{}",user_id);

		List<App_AddressBookInfo> callRecord = appService.getCallRecord(user_id, pageNumber, pageSize);
		int total = appService.listTotal(user_id);
		JsonArrayResult	r = JsonArrayResult.makeSuccessResult(callRecord, total);

		return ResponseEntity.ok(r);
	}
	
	@SuppressWarnings("rawtypes")
	@ModuleService(totalModule=BigMenuConstants.organizationManager,moduleName=ModuleConstants.organizationManager)
	@ApiOperation(value="APP_查询当前组织结构下所有节点及员工")
	@GetMapping(value = {"/app/getOrganizationAndUser"} )
	public ResponseEntity<JsonObjectResult> selectOrgList(@RequestParam(name = "id") String id, 
			@RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize)
	{
		log.info("APP_查询当前组织结构下所有节点及员工:{}",id);
		
		GetAppOrganizationAndUserInfo bean = appService.getOrganizationAndUser(id, pageNumber, pageSize);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(bean);

		return ResponseEntity.ok(r);
    }
	
	@SuppressWarnings("rawtypes")
	@ModuleService(totalModule=BigMenuConstants.organizationManager,moduleName=ModuleConstants.organizationManager)
	@ApiOperation(value="APP_查询通讯录员工详情")
	@GetMapping(value = {"/app/getAddressBookDetail"} )
	public ResponseEntity<JsonObjectResult> getAddressBookDetail(@RequestParam(name = "id") String id)
	{
		log.info("APP_查询通讯录员工详情:{}",id);
		
		App_AddressBookInfo bean = appService.getAddressBookDetail(id);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(bean);

		return ResponseEntity.ok(r);
    }
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_查询通讯录")
	@GetMapping(value = { "/app/getAddressBookList" })
	public ResponseEntity<JsonArrayResult> getAddressBookList(@RequestParam(name = "parm") String parm,
			@RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize) 
	{
		log.info("APP_查询通讯录 :{}",parm);

		List<App_AddressBookInfo> callRecord = appService.getAddressBookList(parm, pageNumber, pageSize);
		int total = appService.getAddressBookListTotal(parm);
		JsonArrayResult	r = JsonArrayResult.makeSuccessResult(callRecord, total);

		return ResponseEntity.ok(r);
	}
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_查询参数表")
	@GetMapping(value = { "/app/getparameterinfo" })
	public ResponseEntity<JsonObjectResult> getparameterinfo(@RequestParam(name = "parm") String parm) 
	{
		log.info("APP_查询参数表 :{}",parm);

		String valueL = appService.getparameterinfo(parm);
		JsonObjectResult	r = JsonObjectResult.makeSuccessResult(valueL);

		return ResponseEntity.ok(r);
	}
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_查询应急法规列表")
	@GetMapping(value = { "/app/statutestudy" })
	public ResponseEntity<JsonArrayResult> list (@RequestParam(name = "s_id") String s_id,@RequestParam(name = "title") String title,
			@RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize)
	{
		log.info("组织结构管理_查询当前组织结构下所有员工:{}",s_id);
		
		List<StatuteStudyList> books = studyService.list(s_id, title, pageNumber, pageSize);
		int total = studyService.listTotal(s_id, title);
		log.info("查询总条数：{}", total);
		JsonArrayResult r = JsonArrayResult.makeSuccessResult(books, total);

		return ResponseEntity.ok(r);
    }
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_查询应急法规详情")
	@GetMapping(value = { "/app/statutestudy/detail" })
	public ResponseEntity<JsonObjectResult> getStudyDetail (@RequestParam(name = "s_id") String s_id)
	{
		log.info("APP_查询应急法规详情:{}",s_id);
		
		StatuteStudyList statute = studyService.getStudyDetail(s_id);
		log.info("APP_查询应急法规详情：{}", statute);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(statute);

		return ResponseEntity.ok(r);
    }
	
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate=true)
	@ApiOperation(value = "APP_记录二维码扫描记录_返回巡检点关联的巡检项目")
	@GetMapping(value = { "/app/plan/sweep" })
	public ResponseEntity<JsonObjectResult> app_planSweep (@RequestParam(name = "s_id") String s_id, @RequestParam(name = "user_id") String user_id)
	{
		log.info("APP_记录二维码扫描记录_返回巡检点关联的巡检项目:{}",s_id);
		
		App_PlanRecordInfo checkInfo = appService.app_planSweep(s_id, user_id);
		log.info("APP_记录二维码扫描记录_返回巡检点关联的巡检项目：{}", checkInfo);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(checkInfo);
		
		return ResponseEntity.ok(r);
    }
	
	
	
	   
    @SuppressWarnings("rawtypes")
    @PermMapping(noValidate=true)
    @ApiOperation(value = "APP_记录二维码扫描记录_插入巡检点项目提交记录")
    @PostMapping(value = { "/app/plan/sweep" })
    public ResponseEntity<JsonObjectResult> app_addPlanSweep (ServletRequest servletRequest, @RequestBody App_AddPlanRecordInfo addInfo)
    {
        log.info("APP_记录二维码扫描记录_插入巡检点关联的巡检项目提交记录:{}",addInfo);
    
        appService.app_addPlanSweep(addInfo);
        log.info("APP_记录二维码扫描记录_插入巡检点关联的巡检项目提交记录：{}", addInfo);
        JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
            
        return ResponseEntity.ok(r);
    }
    
    @ApiOperation(value = "app分页查询应急预案接口")
	@ModuleService(totalModule=BigMenuConstants.emergencyPre,moduleName=ModuleConstants.ENERGENCYPRE)
	@GetMapping(value = { "/app/pre" })
	public ResponseEntity<JsonArrayResult<EmergencyPreRespInfo>> emergencyPreList(@RequestParam(name = "pageNumber") int pageNumber,
			@RequestParam(name = "pageSize") int pageSize, @RequestParam(name = "pre_name") String pre_name,
			@RequestParam(name = "user_id") String user_id,
			@RequestParam(name = "pre_type") String pre_type) {
		JsonArrayResult<EmergencyPreRespInfo> r=null;
		List<EmergencyPreRespInfo> searchList=emergencyPreService.emergencyPreList(pageNumber,pageSize,pre_name,pre_type);
		if(searchList.size()>0) {
			PageInfo<EmergencyPreRespInfo> pages = new PageInfo<EmergencyPreRespInfo>(searchList);
			r = JsonArrayResult.makeSuccessResult(pages.getList(), (int)pages.getTotal());
			return ResponseEntity.ok(r);
		}else {
			r=JsonArrayResult.makeSuccessResult(searchList,0);
			return ResponseEntity.ok(r);
		}	
	}
    
    
    @ApiOperation(value = "app查询应急预案详情接口")
  	@ModuleService(totalModule=BigMenuConstants.emergencyPre,moduleName=ModuleConstants.ENERGENCYPRE)
  	@GetMapping(value = { "/app/preDetails" })
  	public ResponseEntity<JsonArrayResult<EmergencyPreDetailsRespInfo>> emergencyPreList(
  			@RequestParam(name = "id") String id,@RequestParam(name = "user_id") String user_id) {
  		List<EmergencyPreDetailsRespInfo> searchList=emergencyPreService.emergencyPreDetails(id);
  		JsonArrayResult<EmergencyPreDetailsRespInfo> r=JsonArrayResult.makeSuccessResult(searchList,searchList.size());
  			return ResponseEntity.ok(r);
  		}
    
    @ApiOperation(value = "app查询责任人详情接口")
  	@ModuleService(totalModule=BigMenuConstants.emergencyPre,moduleName=ModuleConstants.ENERGENCYPRE)
  	@GetMapping(value = { "/app/dutyDetails" })
  	public ResponseEntity<JsonArrayResult<AppDutyContentInfo>> dutyDetails(
  			@RequestParam(name = "pre_id") String pre_id,@RequestParam(name = "position_id") String position_id,@RequestParam(name = "user_id") String user_id) {
  		List<AppDutyContentInfo> searchList=emergencyPreService.dutyDetailsByApp(pre_id,position_id);
  		JsonArrayResult<AppDutyContentInfo> r=JsonArrayResult.makeSuccessResult(searchList,searchList.size());
  			return ResponseEntity.ok(r);
  		}	
    
    
    
    @ApiOperation(value = "app分页查询计划接口")
	@ModuleService(totalModule=BigMenuConstants.checkManager,moduleName=ModuleConstants.checkPlan)
	@GetMapping(value = { "/app/check/plan" })
	public ResponseEntity<JsonArrayResult<AppCheckPlanRespInfo>> checkPlanList(
			@RequestParam(name = "pageNumber") int pageNumber,@RequestParam(name = "pageSize") int pageSize,
			@RequestParam(name = "user_id") String user_id){
    	JsonArrayResult<AppCheckPlanRespInfo> r=null;
		List<AppCheckPlanRespInfo> searchList = checkManagerService.searchPlanListByApp(pageNumber, pageSize);
		if(searchList.size()>0) {
			PageInfo<AppCheckPlanRespInfo> pages = new PageInfo<AppCheckPlanRespInfo>(searchList);
			r = JsonArrayResult.makeSuccessResult(pages.getList(), (int)pages.getTotal());
			return ResponseEntity.ok(r);
		}else {
			r=JsonArrayResult.makeSuccessResult(searchList,0);
			return ResponseEntity.ok(r);
		}	
	}
    
    @ApiOperation(value = "app查询巡检计划详情接口")
   	@ModuleService(totalModule=BigMenuConstants.checkManager,moduleName=ModuleConstants.checkPlan)
   	@GetMapping(value = { "/app/check/planDetails" })
   	public ResponseEntity<JsonArrayResult<AppCheckPlanDetailsInfo>> checkPlanDetailsByApp(
   			@RequestParam(name = "id") String id,@RequestParam(name = "user_id") String user_id){
    	AppCheckPlanDetailsInfo checkDetails =checkManagerService.checkPlanDetailsByApp(id);
    	List<AppCheckPlanDetailsInfo> list = new ArrayList<AppCheckPlanDetailsInfo>();
    	list.add(checkDetails);
    	JsonArrayResult<AppCheckPlanDetailsInfo> r=JsonArrayResult.makeSuccessResult(list,list.size());;
    	return ResponseEntity.ok(r);
   	}
    
    
    
    @ApiOperation(value = "app查询巡检点详情接口")
   	@ModuleService(totalModule=BigMenuConstants.checkManager,moduleName=ModuleConstants.checkPlan)
   	@GetMapping(value = { "/app/check/pointDetails" })
   	public ResponseEntity<JsonArrayResult<AppCheckPointDetailsInfo>> checkPointDetailsByApp(
   			@RequestParam(name = "id") String id,@RequestParam(name = "user_id") String user_id){
    	AppCheckPointDetailsInfo checkDetails =checkManagerService.checkPointDetailsByApp(id);
    	List<AppCheckPointDetailsInfo> list = new ArrayList<AppCheckPointDetailsInfo>();
    	list.add(checkDetails);
    	JsonArrayResult<AppCheckPointDetailsInfo> r=JsonArrayResult.makeSuccessResult(list,list.size());;
    	return ResponseEntity.ok(r);
   	}
	   
    @ApiOperation(value = "app查询巡检項目详情接口")
   	@ModuleService(totalModule=BigMenuConstants.checkManager,moduleName=ModuleConstants.checkPlan)
   	@GetMapping(value = { "/app/check/itemDetails" })
   	public ResponseEntity<JsonArrayResult<AppCheckItemDetailsInfo>> checkItemDetailsByApp(
   			@RequestParam(name = "id") String id,@RequestParam(name = "user_id") String user_id){
    	AppCheckItemDetailsInfo checkDetails =checkManagerService.checkItemDetailsByApp(id);
    	List<AppCheckItemDetailsInfo> list = new ArrayList<AppCheckItemDetailsInfo>();
    	list.add(checkDetails);
    	JsonArrayResult<AppCheckItemDetailsInfo> r=JsonArrayResult.makeSuccessResult(list,list.size());;
    	return ResponseEntity.ok(r);
   	}
    
    @PermMapping(noValidate = true)
	@ApiOperation(value="app查询_演练计划接口")
	@ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
	@GetMapping(value = {"/app/plan/rehearse"} )
	public ResponseEntity<JsonArrayResult<ExercisePlanInfo>> planListByApp(@RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize,
			@RequestParam(name = "plan_types") String plan_types,@RequestParam(name = "time") String time,@RequestParam(name = "user_id") String user_id
			) {
    	JsonArrayResult<ExercisePlanInfo> r = null;
		List<ExercisePlanInfo> searchList = preExerciseManagerService.searchPreExerciseListByApp(plan_types,time,pageNumber, pageSize);
		if(searchList.size()>0) {
			PageInfo<ExercisePlanInfo> pages =new PageInfo<ExercisePlanInfo>(searchList);
			r = JsonArrayResult.makeSuccessResult(pages.getList(), (int) pages.getTotal());
			return ResponseEntity.ok(r);
		} else {
			r = JsonArrayResult.makeSuccessResult(searchList, 0);
			return ResponseEntity.ok(r);
		}
	}
    
    
    @PermMapping(noValidate = true)
    @ApiOperation(value="app查询_物资管理-查询当前登录员工所有物资储存地点")
    @ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
    @GetMapping(value = {"/app/material/address"} )
    public ResponseEntity<JsonArrayResult<MaterialAddressList>> getMaterialAddressByApp(@RequestParam(name = "pageNumber") int pageNumber, 
            @RequestParam(name = "pageSize") int pageSize, @RequestParam(name = "user_id") String user_id) 
    {
        JsonArrayResult<MaterialAddressList> r = null;
        List<MaterialAddressList> searchList = appService.getMaterialAddressByApp(pageNumber, pageSize, user_id);
        if(searchList.size()>0) {
            PageInfo<MaterialAddressList> pages =new PageInfo<MaterialAddressList>(searchList);
            r = JsonArrayResult.makeSuccessResult(pages.getList(), (int) pages.getTotal());
            return ResponseEntity.ok(r);
        } else {
            r = JsonArrayResult.makeSuccessResult(searchList, 0);
            return ResponseEntity.ok(r);
        }
    }
    
    @PermMapping(noValidate=true)
    @ApiOperation(value = "APP_查询应急物资列表")
    @GetMapping(value = { "/app/material/list" })
    public ResponseEntity<JsonArrayResult<MaterialDetailsList>> materiallist (@RequestParam(name = "user_id") String user_id,
            @RequestParam(name = "address_id") String address_id,
            @RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize)
    {
        log.info("APP_查询登录人员应急物资列表:{}",user_id);
        
        JsonArrayResult<MaterialDetailsList> r = null;
        
        List<MaterialDetailsList> details = appService.materiallist(user_id, address_id, pageNumber, pageSize);
        if(details.size()>0)
        {
            PageInfo<MaterialDetailsList> pages =new PageInfo<MaterialDetailsList>(details);
            r = JsonArrayResult.makeSuccessResult(pages.getList(), (int) pages.getTotal());
            return ResponseEntity.ok(r);
        } 
        else 
        {
            r = JsonArrayResult.makeSuccessResult(details, 0);
            return ResponseEntity.ok(r);
        }
    }
    
    @SuppressWarnings("rawtypes")
    @PermMapping(noValidate=true)
    @ApiOperation(value = "APP_插入用户物资巡检记录")
    @PostMapping(value = { "/app/material/record" })
    public ResponseEntity<JsonObjectResult> insertMaterialRecord(ServletRequest servletRequest, @RequestBody MaterialDetailRecordInfo info) 
    {
        
        log.info("APP_插入用户物资巡检记录:{}",info);
        JsonObjectResult r = null;
        boolean flag = appService.insertMaterialRecord(info);
        if(flag)
        {
            r = JsonObjectResult.makeSuccessResult(null);
        }
        else
        {
            r = JsonObjectResult.makeErrorResult("物资使用数量错误！");
        }
        return ResponseEntity.ok(r);
    }
    
    
    @PermMapping(noValidate=true)
    @ApiOperation(value = "APP_查询用户物资巡检记录列表")
    @GetMapping(value = { "/app/material/record" })
    public ResponseEntity<JsonArrayResult<MaterialDetailRecordInfo>> getMaterialRecordList(@RequestParam(name = "user_id") String user_id,
            @RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize) 
    {
        
        log.info("APP_查询用户物资巡检记录列表:{}",user_id);
        JsonArrayResult<MaterialDetailRecordInfo> r = null;
        
        List<MaterialDetailRecordInfo> details = appService.getMaterialRecordList(user_id, pageNumber, pageSize);
        if(details.size()>0)
        {
            PageInfo<MaterialDetailRecordInfo> pages =new PageInfo<MaterialDetailRecordInfo>(details);
            r = JsonArrayResult.makeSuccessResult(pages.getList(), (int) pages.getTotal());
            return ResponseEntity.ok(r);
        } 
        else 
        {
            r = JsonArrayResult.makeSuccessResult(details, 0);
            return ResponseEntity.ok(r);
        }
    }
    
    
    @SuppressWarnings("rawtypes")
    @ApiOperation(value = "APP_查询用户物资巡检记录详情接口")
    @GetMapping(value = { "/app/material/record/detail" })
    public ResponseEntity<JsonObjectResult> getMaterialRecordDetail(
            @RequestParam(name = "id") String id)
    {
    
        MaterialDetailRecordInfoList details  = appService.getMaterialRecordDetail(id);
        JsonObjectResult r=JsonObjectResult.makeSuccessResult(details);
        return ResponseEntity.ok(r);
    }
    
    @PermMapping(noValidate = true)
  	@ApiOperation(value="app查询_演练资料接口")
  	@ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
  	@GetMapping(value = {"/app/plan/data"} )
  	public ResponseEntity<JsonArrayResult<APPExerciseDataRespInfo>> planDataByApp(@RequestParam(name = "pageNumber") int pageNumber, @RequestParam(name = "pageSize") int pageSize,
    @RequestParam(name = "user_id") String user_id
  			) {
      	JsonArrayResult<APPExerciseDataRespInfo> r = null;
  		List<APPExerciseDataRespInfo> searchList = preExerciseManagerService.searchPlanDataByApp(pageNumber, pageSize,user_id);
  		if(searchList.size()>0) {
  			PageInfo<APPExerciseDataRespInfo> pages =new PageInfo<APPExerciseDataRespInfo>(searchList);
  			r = JsonArrayResult.makeSuccessResult(pages.getList(), (int) pages.getTotal());
  			return ResponseEntity.ok(r);
  		} else {
  			r = JsonArrayResult.makeSuccessResult(searchList, 0);
  			return ResponseEntity.ok(r);
  		}
  	}
    
    @PermMapping(noValidate = true)
	@ApiOperation(value="app查询_演练资料详情接口")
	@ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
	@GetMapping(value = {"/app/plan/DataDetails"} )
	public ResponseEntity<JsonArrayResult<ExercisePlanDataRespInfo>> dataDetails(
			@RequestParam(name = "id") String id) {
		
		ExercisePlanDataRespInfo searchList = preExerciseManagerService.searchdataDetails(id);
		List<ExercisePlanDataRespInfo> list =new ArrayList<ExercisePlanDataRespInfo>();
		list.add(searchList);
		JsonArrayResult<ExercisePlanDataRespInfo> r = JsonArrayResult.makeSuccessResult(list, 1);
		return ResponseEntity.ok(r);
	}
    
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate = true)
	@ApiOperation(value="app添加_应急演练总结接口")
	@PostMapping(value = {"/app/summary"} )
	public ResponseEntity<JsonObjectResult>  appConclusInfo( @RequestBody APPExerciseConclusionReqInfo appConReqInfo) {
		 preExerciseManagerService.appConclusInfo(appConReqInfo);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
		return ResponseEntity.ok(r);
	}
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate = true)
	@ApiOperation(value="app添加_应急延迟演练接口")
	@PostMapping(value = {"/app/delay"} )
	public ResponseEntity<JsonObjectResult>  appPlanDelay( @RequestBody APPExerciseDelayReqInfo planDelay) {
		 preExerciseManagerService.appPlanDelay(planDelay);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
		return ResponseEntity.ok(r);
	}
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate = true)
	@ApiOperation(value="app添加_是否同意延迟演练接口")
	@PostMapping(value = {"/app/ifDelay"} )
	public ResponseEntity<JsonObjectResult>  agreeDelay( @RequestBody IfAgreePlanDelayInfo ifDelay) {
		if("0".equals(ifDelay.getState())) {
			//同意延迟
			preExerciseManagerService.agreeDelay(ifDelay.getId());
		}else if ("1".equals(ifDelay.getState())) {
			//不同意
			preExerciseManagerService.notAgreeDelay(ifDelay.getId());
		}
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
		return ResponseEntity.ok(r);
	}
	
	
	@SuppressWarnings("rawtypes")
	@PermMapping(noValidate = true)
	@ApiOperation(value="app添加_执行演练_演练基本信息")
	@PostMapping(value = {"/app/perform"} )
	public ResponseEntity<JsonObjectResult>  performPlan( @RequestBody APPExerciseBasicReqInfo appConReqInfo) {
		 preExerciseManagerService.performPlan(appConReqInfo);
		JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
		return ResponseEntity.ok(r);
	}
    
    @PermMapping(noValidate = true)
    @ApiOperation(value="app查询_演练资料详情接口计划_演练现场记录")
    @ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
    @GetMapping(value = {"/app/drill/record"} )
    public ResponseEntity<JsonArrayResult<App_DrillRecordCatalogList>> dataDrillRecord(
            @RequestParam(name = "type") String type) 
    {
        List<App_DrillRecordCatalogList> list = appService.dataDrillRecord(type);
        JsonArrayResult<App_DrillRecordCatalogList> r = JsonArrayResult.makeSuccessResult(list, 1);
        return ResponseEntity.ok(r);
    }
    
    @SuppressWarnings("rawtypes")
    @PermMapping(noValidate = true)
    @ApiOperation(value="app添加_执行演练_演练基本信息_New")
    @PostMapping(value = {"/app/perform_new"} )
    public ResponseEntity<JsonObjectResult>  performPlan_new( @RequestBody APPExerciseBasicReqInfo_wcc appConReqInfo) 
    {
        
        log.info("***************************************app添加_执行演练_演练基本信息_New:{}",appConReqInfo);
        preExerciseManagerService.performPlan_new(appConReqInfo);
        JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
        return ResponseEntity.ok(r);
    }
    
    @PermMapping(noValidate = true)
    @ApiOperation(value="app查询_演练资料详情接口计划_演练现场记录答题答案")
    @ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
    @GetMapping(value = {"/app/drill/record/answer"} )
    public ResponseEntity<JsonArrayResult<App_DrillRecordCatalogList>> dataDrillRecordAnswer(
            @RequestParam(name = "id") String id) 
    {
        List<App_DrillRecordCatalogList> list = appService.dataDrillRecordAnswer(id);
        JsonArrayResult<App_DrillRecordCatalogList> r = JsonArrayResult.makeSuccessResult(list, 1);
        return ResponseEntity.ok(r);
    }
    
    
    @SuppressWarnings("rawtypes")
    @PermMapping(noValidate = true)
    @ApiOperation(value="app查询_演练资料详情接口计划_查询预案演练总结")
    @ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
    @GetMapping(value = {"/app/exist_ques"} )
    public ResponseEntity<JsonObjectResult> dataExist_ques(
            @RequestParam(name = "id") String id) 
    {
        APPExerciseConclusionReqInfo info = appService.dataExist_ques(id);
        JsonObjectResult r = JsonObjectResult.makeSuccessResult(info);
        return ResponseEntity.ok(r);
    }
    
    @SuppressWarnings("rawtypes")
    @PermMapping(noValidate = true)
    @ApiOperation(value="app查询_演练资料详情接口计划_插入预案演练反馈")
    @ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
    @PostMapping(value = {"/app/exist_feedback"} )
    public ResponseEntity<JsonObjectResult> exist_feedback(@RequestBody APPExerciseFeedBack feedback) 
    {
        appService.exist_feedback(feedback);
        JsonObjectResult r = JsonObjectResult.makeSuccessResult(null);
        return ResponseEntity.ok(r);
    }
    
    @PermMapping(noValidate = true)
    @ApiOperation(value="app查询_演练资料详情接口计划_查询预案反馈")
    @ModuleService(totalModule=BigMenuConstants.preExercise,moduleName=ModuleConstants.exercisePlan)
    @GetMapping(value = {"/app/exist_feedback"} )
    public ResponseEntity<JsonArrayResult<APPExerciseFeedBack_Detail>> getExist_feedback(@RequestParam(name = "id") String id) 
    {
        List<APPExerciseFeedBack_Detail> list = appService.getExist_feedback(id);
        JsonArrayResult<APPExerciseFeedBack_Detail> r = JsonArrayResult.makeSuccessResult(list, 1);
        return ResponseEntity.ok(r);
    }
}
